package m.jclecai.com.adapter.klsfRecyclerAdapter;

import java.util.List;

import m.jclecai.com.R;
import m.jclecai.com.base.recyclerview.BaseRecyclerViewAdapter;
import m.jclecai.com.base.recyclerview.BaseViewHolder;
import m.jclecai.com.bean.MissDataBean;

/**
 * Created by andy on 2017/7/8.
 */

public class HistoryAdapter extends BaseRecyclerViewAdapter<MissDataBean.Codes> {

    private String mType ="";

    public HistoryAdapter(List<MissDataBean.Codes> DList) {
        super(DList);
    }

    @Override
    public int getItemView() {
        return R.layout.item_list_pls_sd_qxca;
    }

    @Override
    protected void bindViewHolder(BaseViewHolder holder, MissDataBean.Codes bean, int position) {

        MissDataBean.Codes codes = bean;
        String term = codes.getIssue();
        String[] split = codes.getCode().split(",");
        String number = "";
        for (String s : split) {
            number += s + "  ";
        }

        if (term.length() > 7) {
            //2017062834，这里表示按天算；
            term = term.substring(term.length() - 2) + "期";
        } else {
            //2017170,这里表示按年算；
            term = term.substring(term.length() - 3) + "期";
        }
        if (mType.equals("bjkl8") || mType.equals("pk10"))
            term = codes.getIssue();
        holder.getTextView(R.id.tv_term).setText(term);
        //这里我们要做的一个操作就是将数据进行一个填充；
        holder.getTextView(R.id.tv_number).setText(number);
    }

    public void setType(String type) {
        this.mType = type;
    }
}

